#!/usr/bin/env python

from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
import abbrs

def job_func():
    import os
    print(f'{abbrs.get_time_str()}: upload')
    os.system('./git_push.sh')

scheduler = BlockingScheduler(timezone="Asia/Shanghai")
    # An error may occur if timezone not explictly set:
    #   Timezone offset does not match system offset: 0 != -32400. Please, check your config files
scheduler.add_job(job_func, 'interval', minutes=60)

"""
scheduler.add_job(job_func, 'cron', hour=0, minute=55) # Campus network closes at 1 a.m.
    # 5 minute left for pulling
"""

if __name__ == '__main__':
    print('Scheduler on.')
    scheduler.start()